home *** CD-ROM | disk | FTP | other *** search
/ CU Amiga Super CD-ROM 19 / CU Amiga Magazine's Super CD-ROM 19 (1998)(EMAP Images)(GB)[!][issue 1998-02].iso / CUCD / Readers / Gui4Cli / Docs / Tutorials / GoSub.gc < prev    next >
Text File  |  1997-12-02  |  4KB  |  136 lines

  1. G4C
  2.  
  3. WinBig -1 -1 300 210 "GoSub.gc"
  4. WinType 11110001
  5. usetopaz   ; we force the use of topaz font for lining up..
  6.  
  7. ; -------------------------------------------------------------
  8. ;     This is all the diagram stuff ...
  9. ; -------------------------------------------------------------
  10.  
  11. BOX 0 0 0 0 OUT RIDGE
  12. SQUARE 10 24 40 16 2 NOFILL
  13. SQUARE 20 50 20 10 2 FILL
  14. SQUARE 20 70 20 10 2 FILL
  15. SQUARE 20 90 20 10 2 FILL
  16. SQUARE 10 110 40 16 2 NOFILL
  17. LINE 30 40 30 110 2
  18.  
  19. LINE 40 55 120 55 2
  20. LINE 40 75 120 75 2
  21. LINE 40 95 120 95 2
  22. LINE 4 134 294 134 1
  23.  
  24. ; -------------------------------------------------------------
  25. ;     System events
  26. ; -------------------------------------------------------------
  27.  
  28. xonLoad 
  29. GuiOpen GoSub.gc
  30.  
  31. xonClose
  32. GuiQuit GoSub.gc
  33.  
  34. ; -------------------------------------------------------------
  35. ;     The main contents start here ...
  36. ;     The texts
  37. ; -------------------------------------------------------------
  38.  
  39. Text 80 2 100 12 'GoSub and xRoutine' 206 NOBOX 
  40. Text 80 20 200 10 'Click on the "Gosub"' 20 NOBOX
  41. Text 80 30 200 10 'buttons to see the action.' 26 NOBOX
  42. Text 80 114 200 10 'Then read the script.' 22 NOBOX
  43. Text 20 27 32 12 'In' 2 NOBOX
  44. Text 18 113 32 12 'Out' 3 NOBOX
  45.  
  46. ; -------------------------------------------------------------
  47. ;     Three buttons to call the subroutines
  48.  
  49. ;     In this case, we'll keep the calls themselves simple :  
  50. ;         gosub GuiName RoutineName
  51.  
  52. ;     Note however, that Gosub routines, as well as GuiLoad, 
  53. ;     GuiOpen etc can take and return arguments, making them much 
  54. ;     more powerfull than is shown here..
  55.  
  56. ; -------------------------------------------------------------
  57.  
  58. xButton 120 50 80 12 'Gosub 1'
  59. gosub GoSub.gc SubRoutine1
  60.  
  61. xButton 120 70 80 12 'Gosub 2'
  62. gosub GoSub.gc SubRoutine2
  63.  
  64. xButton 120 90 80 12 'Gosub 3'
  65. gosub GoSub.gc SubRoutine3
  66.  
  67. ; -------------------------------------------------------------
  68. ;     Labels and empty strings for the output
  69. ;     from the subroutines
  70. ; -------------------------------------------------------------
  71.  
  72. Text 14 140 34 16 ' 1' 2 BOX
  73. gadid 1
  74. Text 14 160 34 16 ' 2' 2 BOX
  75. gadid 2
  76. Text 14 180 34 16 ' 3' 2 BOX
  77. gadid 3
  78.  
  79. Text 60 142 34 16 ' ' 30 NOBOX
  80. gadid 4
  81. Text 60 162 34 16 ' ' 30 NOBOX
  82. gadid 5
  83. Text 60 172 34 16 ' ' 30 NOBOX
  84. gadid 6
  85. Text 60 182 34 16 ' ' 30 NOBOX
  86. gadid 7
  87.  
  88. ; -------------------------------------------------------------
  89. ;      Here are the subroutines themselves.  All of this is :
  90. ; -------------------------------------------------------------
  91.  
  92. ;  1. Very easy to call repeatedly if needed.
  93. ;  2. Well clear of the main script (especially useful for
  94. ;     complex arithmetic or file-handling procedures).
  95.  
  96. ;  In fact, these examples are utterly trivial, since all they do is
  97. ;  update the contents of 7 text gadgets which are already in place.
  98.  
  99. ;  The xRoutine names MUST match those called by the 'gosub' commands.
  100.   
  101. ; -------------------------------------------------------------
  102.  
  103. xRoutine SubRoutine1
  104. Update GoSub.gc 1 ' 1'
  105. Update GoSub.gc 2 '  '
  106. Update GoSub.gc 3 '  '
  107. Update GoSub.gc 4 "Subroutine 1 advises :"
  108. Update GoSub.gc 5 " Subroutines are easy to"
  109. Update GoSub.gc 6 " call when you have any"
  110. Update GoSub.gc 7 " repetitive tasks."
  111.  
  112. ; -------------------------------------------------------------
  113.  
  114. xRoutine SubRoutine2
  115. Update GoSub.gc 1 '  '
  116. Update GoSub.gc 2 ' 2'
  117. Update GoSub.gc 3 '  '
  118. Update GoSub.gc 4 "Subroutine 2 suggests :"
  119. Update GoSub.gc 5 " Subroutines can help keep"
  120. Update GoSub.gc 6 " your main script clear"
  121. Update GoSub.gc 7 " and easier to read."
  122.  
  123. ; -------------------------------------------------------------
  124.  
  125. xRoutine SubRoutine3
  126. Update GoSub.gc 1 '  '
  127. Update GoSub.gc 2 '  '
  128. Update GoSub.gc 3 ' 3'
  129. Update GoSub.gc 4 "Subroutine 3 proclaims :"
  130. Update GoSub.gc 5 " Subroutines are an example"
  131. Update GoSub.gc 6 " of modular programming"
  132. Update GoSub.gc 7 " and help you think clearly."
  133.  
  134.  
  135.  
  136.